package top.lidee.module.backendApi.twice.management.controller;

import java.util.Arrays;
import java.util.Map;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import top.lidee.common.service.twice.management.TFullNameOfBankService;
import top.lidee.framework.result.PageUtils;
import top.lidee.framework.result.ResponseResult;
import top.lidee.repository.model.twice.pojo.management.TFullNameOfBankEntity;


/**
 * 开户银行全称对照表（微信）
 *
 * @author zhangzhan
 * @email 52194440@qq.com
 * @date 2024-10-23 15:12:03
 */
@Api("开户银行全称对照表（微信）")
@RestController
@RequestMapping("/backendApi/tfullnameofbank")
public class TFullNameOfBankController {
    @Autowired
    private TFullNameOfBankService tFullNameOfBankService;

    /**
     * 列表
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ApiOperation(value = "开户银行全称对照表（微信）列表")
    public ResponseResult list(@RequestBody Map<String, Object> params) {
        PageUtils page = tFullNameOfBankService.queryPage(params);

        return ResponseResult.okResultPage("page", page);
    }

    /**
     * 根据名称模糊查询
     */
    @RequestMapping(value = "/listByName/{fullName}", method = RequestMethod.GET)
    @ApiOperation(value = "根据名称模糊查询")
    public ResponseResult listByName(@PathVariable("fullName") String fullName) {
        return ResponseResult.okResult(tFullNameOfBankService.listByName(fullName));
    }


    /**
     * 信息
     */
    @RequestMapping(value = "/info/{clearingNumber}", method = RequestMethod.GET)
    @ApiOperation(value = "开户银行全称对照表（微信）信息")
    public ResponseResult info(@PathVariable("clearingNumber") String clearingNumber) {
        TFullNameOfBankEntity tFullNameOfBank = tFullNameOfBankService.getById(clearingNumber);

        return ResponseResult.okResultPage("TFullNameOfBank", tFullNameOfBank);
    }

    /**
     * 保存
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ApiOperation(value = "开户银行全称对照表（微信）保存")
    public ResponseResult save(@RequestBody TFullNameOfBankEntity tFullNameOfBank) {
        tFullNameOfBankService.save(tFullNameOfBank);

        return ResponseResult.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update", method = RequestMethod.PUT)
    @ApiOperation(value = "开户银行全称对照表（微信）修改")
    public ResponseResult update(@RequestBody TFullNameOfBankEntity tFullNameOfBank) {
        tFullNameOfBankService.updateById(tFullNameOfBank);

        return ResponseResult.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    @ApiOperation(value = "开户银行全称对照表（微信）删除")
    public ResponseResult delete(@RequestBody String[] clearingNumbers) {
        tFullNameOfBankService.removeByIds(Arrays.asList(clearingNumbers));

        return ResponseResult.ok();
    }

}
